﻿<!DOCTYPE html>
<!-- saved from url=(0029)http://insight.webm.vn/report -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <title>BuzzInsight</title>
    <link href="./BuzzInsight_files/style.css" rel="stylesheet" type="text/css">

    <link href="./BuzzInsight_files/jquery-ui-1.10.3.custom.css" rel="stylesheet" type="text/css">
    <script src="./BuzzInsight_files/jquery-1.9.1.js"></script>
    <script src="./BuzzInsight_files/jquery-ui-1.10.3.custom.js"></script>
    <script type="text/javascript" src="./BuzzInsight_files/jquery.loading.js"></script>

    <script type="text/javascript" src="./BuzzInsight_files/shortcut.js"></script>
    <script type="text/javascript" src="./BuzzInsight_files/jquery.confirm.js"></script>
    <link href="./BuzzInsight_files/jquery.confirm.css" rel="stylesheet" type="text/css">

<style type="text/css" id="vakata-stylesheet">#vakata-dragged { display:block; margin:0 0 0 0; padding:4px 4px 4px 24px; position:absolute; top:-2000px; line-height:16px; z-index:10000; } #vakata-contextmenu { display:block; visibility:hidden; left:0; top:-200px; position:absolute; margin:0; padding:0; min-width:180px; background:#ebebeb; border:1px solid silver; z-index:10000; *width:180px; } #vakata-contextmenu ul { min-width:180px; *width:180px; } #vakata-contextmenu ul, #vakata-contextmenu li { margin:0; padding:0; list-style-type:none; display:block; } #vakata-contextmenu li { line-height:20px; min-height:20px; position:relative; padding:0px; } #vakata-contextmenu li a { padding:1px 6px; line-height:17px; display:block; text-decoration:none; margin:1px 1px 0 1px; } #vakata-contextmenu li ins { float:left; width:16px; height:16px; text-decoration:none; margin-right:2px; } #vakata-contextmenu li a:hover, #vakata-contextmenu li.vakata-hover > a { background:gray; color:white; } #vakata-contextmenu li ul { display:none; position:absolute; top:-2px; left:100%; background:#ebebeb; border:1px solid gray; } #vakata-contextmenu .right { right:100%; left:auto; } #vakata-contextmenu .bottom { bottom:-1px; top:auto; } #vakata-contextmenu li.vakata-separator { min-height:0; height:1px; line-height:1px; font-size:1px; overflow:hidden; margin:0 2px; background:silver; /* border-top:1px solid #fefefe; */ padding:0; } </style><style type="text/css" id="jstree-stylesheet">.jstree ul, .jstree li { display:block; margin:0 0 0 0; padding:0 0 0 0; list-style-type:none; } .jstree li { display:block; min-height:18px; line-height:18px; white-space:nowrap; margin-left:18px; min-width:18px; } .jstree-rtl li { margin-left:0; margin-right:18px; } .jstree > ul > li { margin-left:0px; } .jstree-rtl > ul > li { margin-right:0px; } .jstree ins { display:inline-block; text-decoration:none; width:18px; height:18px; margin:0 0 0 0; padding:0; } .jstree a { display:inline-block; line-height:16px; height:16px; color:black; white-space:nowrap; text-decoration:none; padding:1px 2px; margin:0; } .jstree a:focus { outline: none; } .jstree a > ins { height:16px; width:16px; } .jstree a > .jstree-icon { margin-right:3px; } .jstree-rtl a > .jstree-icon { margin-left:3px; margin-right:0; } li.jstree-open > ul { display:block; } li.jstree-closed > ul { display:none; } #vakata-dragged ins { display:block; text-decoration:none; width:16px; height:16px; margin:0 0 0 0; padding:0; position:absolute; top:4px; left:4px;  -moz-border-radius:4px; border-radius:4px; -webkit-border-radius:4px; } #vakata-dragged .jstree-ok { background:green; } #vakata-dragged .jstree-invalid { background:red; } #jstree-marker { padding:0; margin:0; font-size:12px; overflow:hidden; height:12px; width:8px; position:absolute; top:-30px; z-index:10001; background-repeat:no-repeat; display:none; background-color:transparent; text-shadow:1px 1px 1px white; color:black; line-height:10px; } #jstree-marker-line { padding:0; margin:0; line-height:0%; font-size:1px; overflow:hidden; height:1px; width:100px; position:absolute; top:-30px; z-index:10000; background-repeat:no-repeat; display:none; background-color:#456c43;  cursor:pointer; border:1px solid #eeeeee; border-left:0; -moz-box-shadow: 0px 0px 2px #666; -webkit-box-shadow: 0px 0px 2px #666; box-shadow: 0px 0px 2px #666;  -moz-border-radius:1px; border-radius:1px; -webkit-border-radius:1px; }.jstree .jstree-real-checkbox { display:none; } .jstree-themeroller .ui-icon { overflow:visible; } .jstree-themeroller a { padding:0 2px; } .jstree-themeroller .jstree-no-icon { display:none; }.jstree .jstree-wholerow-real { position:relative; z-index:1; } .jstree .jstree-wholerow-real li { cursor:pointer; } .jstree .jstree-wholerow-real a { border-left-color:transparent !important; border-right-color:transparent !important; } .jstree .jstree-wholerow { position:relative; z-index:0; height:0; } .jstree .jstree-wholerow ul, .jstree .jstree-wholerow li { width:100%; } .jstree .jstree-wholerow, .jstree .jstree-wholerow ul, .jstree .jstree-wholerow li, .jstree .jstree-wholerow a { margin:0 !important; padding:0 !important; } .jstree .jstree-wholerow, .jstree .jstree-wholerow ul, .jstree .jstree-wholerow li { background:transparent !important; }.jstree .jstree-wholerow ins, .jstree .jstree-wholerow span, .jstree .jstree-wholerow input { display:none !important; }.jstree .jstree-wholerow a, .jstree .jstree-wholerow a:hover { text-indent:-9999px; !important; width:100%; padding:0 !important; border-right-width:0px !important; border-left-width:0px !important; } .jstree .jstree-wholerow-span { position:absolute; left:0; margin:0px; padding:0; height:18px; border-width:0; padding:0; z-index:0; }</style><link rel="stylesheet" type="text/css" media="all" href="./BuzzInsight_files/style(1).css"><style type="text/css" id="jstree-types-stylesheet">.jstree-0 a > .jstree-icon {  background-image:url(http://insight.webm.vn/public/jtree/images/file.png);  background-position:0 0; } .jstree-0 li[rel="folder"] > a > .jstree-icon {  background-image:url(http://insight.webm.vn/public/jtree/images/folder.png);  background-position:0 0; } .jstree-0 li[rel="drive"] > a > .jstree-icon {  background-image:url(http://insight.webm.vn/public/jtree/images/root.png);  background-position:0 0; } </style></head>
<body>
<link href="http://insight.webm.vn/public/jtree/css/style.css" rel="stylesheet">
<!-- Query tree -->
<script type="text/javascript" src="./BuzzInsight_files/jquery.cookie.js"></script>
<script type="text/javascript" src="./BuzzInsight_files/jquery.hotkeys.js"></script>
<script type="text/javascript" src="./BuzzInsight_files/jquery.jstree.js"></script>
<script type="text/javascript" src="./BuzzInsight_files/!script.js"></script>

<!-- Language and smt filter-->
<link rel="stylesheet" href="http://insight.webm.vn/public/bootstrap/bootstrap-combined.min.css">
<link rel="stylesheet" type="text/css" href="./BuzzInsight_files/bootstrap-select.css">
<link rel="stylesheet" type="text/css" href="./BuzzInsight_files/bootstrap.min.css">
<script type="text/javascript" src="./BuzzInsight_files/bootstrap-select.js"></script>
<script src="./BuzzInsight_files/bootstrap.min.js"></script>

<script type="text/javascript" src="./BuzzInsight_files/moment.min.js"></script>
<script type="text/javascript" src="./BuzzInsight_files/daterangepicker.js"></script>
<link rel="stylesheet" type="text/css" href="./BuzzInsight_files/daterangepicker-bs3.css">
<script type="text/javascript" src="./BuzzInsight_files/jquery.infieldlabel.js"></script>

<!-- CodeMirror-->
<!--
<link rel="stylesheet" href="http://insight.webm.vn/public/codemirror/lib/codemirror.css">
<link rel="stylesheet" href="http://insight.webm.vn/public/codemirror/addon/hint/show-hint.css">
<script src="http://insight.webm.vn/public/codemirror/lib/codemirror.js"></script>
<script src="http://insight.webm.vn/public/codemirror/addon/hint/show-hint.js"></script>
<script src="http://insight.webm.vn/public/codemirror/addon/hint/javascript-hint.js"></script>
<script src="http://insight.webm.vn/public/codemirror/mode/javascript/javascript.js"></script>-->

<script type="text/javascript" src="./BuzzInsight_files/report.js"></script>
<link href="./BuzzInsight_files/option.css" rel="stylesheet" type="text/css">

<script>
    $(function () {
        //set index-query
        $.cookie("index-query",0);
        //Init date picker
        $('#duration').daterangepicker({
            format: 'MM/DD/YYYY',
            ranges: {
                'This week': [moment().subtract('days', (moment().day() || 7) - 1), moment()],
                'Last 7 days': [moment().subtract('days', 6), moment()],
                'Last week': [moment().subtract('days', (moment().day() || 7) - 1 + 7), moment().subtract('days', moment().day() || 7)],
                'This month': [moment().startOf('month'), moment()],
                'Last 30 days': [moment().subtract('days', 29), moment()],
                'Last month': [moment().subtract('month', 1).startOf('month'), moment().subtract('month', 1).endOf('month')]
            }
        });

        //Init tab
        var index = 1;

        var tabs = $("#tabs").tabs({
            activate: function(event, ui) {
                var old = ui.oldPanel;
                var tnew = ui.newPanel;
                // frame download dialog by Do Tuan
                frame = tnew.find('#download-frame-dialog');
                frame.contents().find("#divLoading").find('span[class*="l-"]').css("display","none");
                setTimeout(function(){
                    frame.contents().find("#divLoading").find('span[class*="l-"]').css("display","inline-block");
                },100);
                // frame loading
                reportframe = tnew.find('.report-frame');
                reportframe.contents().find("#loading").find('span[class*="l-"]').css("display","none");
                setTimeout(function(){
                    reportframe.contents().find("#loading").find('span[class*="l-"]').css("display","inline-block");
                },100);
            }

        });

        var report = $("#report");
        var query  = $('#query');

        function create() {
            var type = $('input[name=reportType]:checked', '#report').val();
            var language = $('#language').val();
            var begin = $('#begin').val();
            var end = $('#end').val();
            var smt = $('#smtFilter').val();
            var duration = $('.ranges').find('.active').text();

            var label = '<img src="views/public/images/'+type+'.png" />'+" Report " + index,
                id = "tabs-" + index,
                li = $('<li><a class="tab-report" href="#' + id + '">' + label + '</a><span class="ui-icon ui-icon-close" role="presentation">Remove Tab</span></li>'),
                tabContentHtml;

            //Toolbar
            tabContentHtml = '\
            <div class="toolbar">\
                <span class="total"></span>\
                <form method="post" target="download-frame-' + index + '" action="http://insight.webm.vn/' + type + '/download">\
                    <input type="hidden" id="total-number" name="total" value="" />\
                    <input type="hidden" name="begin" value="' + begin + '" />\
                    <input type="hidden" name="end" value="'+ end +' "/>';

            //Nhap list ngon ngu vao form download
            try{
                size = language.length;
            }catch (err){
                size = 0;
            }
            tabContentHtml += '<select name="language[]" multiple style="display:none;">'
            for (i = 0; i < size; i++){
                    tabContentHtml += '<option value="' + language[i] + '" selected></option>';
            }
            tabContentHtml += '</select>';
            //Nhap list smt vao form download
            size = smt.length;
            tabContentHtml += '<select name="smt-filter[]" multiple style="display:none;">'
            for (i = 0; i < size; i++){
                tabContentHtml += '<option value="' + smt[i] + '" selected></option>';
            }
            tabContentHtml += '</select>';


            if (type == 'trends' || type == 'sov'){
                $(".query textarea").each(function() {
                    tabContentHtml += '<textarea class="list_query" style="display: none;" name="query[]">' + $(this).val() + '</textarea>';
                });

                $(".list input[name='query-name[]']").each(function() {
                    tabContentHtml += '<input class="list_query_name" type="hidden" name="query-name[]" value="' + $(this).val() + '" />';
                });

            }
            else{
                tabContentHtml += '<textarea style="display: none;" name="query">'+ query.val() + '</textarea>';
            }

            if (type == 'messages' || type == 'leads'){
                tabContentHtml += '<button onclick="showDownloadDialog(this);" title="Download" id="download" />';
                tabContentHtml += '<input type="text" readonly id="limitControl" name="limit" onclick="changeLitmitValue(this)" value="5000" />';
            }
            else{
                tabContentHtml += '<button onclick="showDownloadDialog(this);" type="submit" title="Download" id="download" />';
            }

            // Save report
            tabContentHtml += '<div id="saveReport" class="saveReport">';
            tabContentHtml += '<button title="Save Report" onclick="showReportName(this);" id="save" />';
            tabContentHtml += '<input type="text" readonly id="saveLabel" onclick="showReportName(this);" value="Report '+index+'" />';
            tabContentHtml += '<div id="SaveReportName">';
            tabContentHtml += '<b>Save Report</b>';
            tabContentHtml += '<span class="closeSaveReport" onclick="closeSaveReport(this);"></span>';
            tabContentHtml += '<hr>';
            tabContentHtml += '<div class="SaveReportText" >';
            tabContentHtml += '<input type="text" onkeyup="changeTextSaveReport(this, '+index+');" autocomplete="off" value="Report '+index+'" id="SaveReportTextName" />';
            tabContentHtml += '<button title="Save Report" onclick="saveReport('+index+','+"'"+type+"'"+','+"'"+query.val()+"'"+','+"'"+duration+"'"+','+"'"+smt+"'"+','+"'"+language+"'"+');" >Save</button>';
            tabContentHtml += '</div>';
            tabContentHtml += '<p id="saveReportAlert"></p>';
            tabContentHtml += '</div>';
            tabContentHtml += '</div>';

            tabContentHtml += '\
                </form>\
            </div>';

            //Connection progress bar
            tabContentHtml += '<div id="progress">\
                                    <div id="loadingSpan">\
                                        <span id="loadingHeader">Connecting</span>\
                                        <span class="l-1"></span>\
                                        <span class="l-2"></span>\
                                        <span class="l-3"></span>\
                                        <span class="l-4"></span>\
                                        <span class="l-5"></span>\
                                        <span class="l-6"></span>\
                                    </div>\
                                </div>';
            tabContentHtml += '<div class="download-frame"><div class="download-content"><span class="close" onclick="closeDownloadDialog(this)"><img src="views/public/images/manager-del.png"></span><iframe id="download-frame-dialog" name="download-frame-' + index + '"></iframe></div></div>';
            //Iframe
            tabContentHtml += '<iframe id="frame-' + index + '" name="frame-' + index + '" class="report-frame"></iframe>';

            tabs.find(".ui-tabs-nav").append(li);
            tabs.append("<div id='" + id + "'>" + tabContentHtml + "</div>");
            tabs.tabs("refresh");
            tabs.tabs("option", "active", tabs.children().size() - 2);
            report.prop("target", "frame-" + index);
            report.prop("action", "http://insight.webm.vn/" + type + "?begin=" + begin + "&end=" + end );
            report.submit();
            index++;
        }

        $("#create").click(function () {
            if (!query.val()) {
                query.effect('highlight', {color: '#ffeddc'}, 600)
                    .effect('highlight', {color: '#ffeddc'}, 600);
                query.focus();
                return false;
            }
            logCreate();
            create();
        });
        function logCreate(){
            var type = $('input[name=reportType]:checked').val();
            var query = document.getElementById("query").value;
            $.post('http://insight.webm.vn/report/runLogCreate',{ action: "Create", type: type, query: query } , function(data) {
            });
        }
        /** Shortcut key */
        shortcut.add("ctrl+enter", function() {
            if (!query.val()) {
                query.effect('highlight', {color: '#ffeddc'}, 600)
                    .effect('highlight', {color: '#ffeddc'}, 600);
                query.focus();
            }else{
                create();
            }

        });
        // close icon: removing the tab on click
        tabs.delegate("span.ui-icon-close", "click", function () {
            var id = $(this).closest("li").remove().attr("aria-controls");
            $("#" + id).remove();
            tabs.tabs("refresh");
        });
        //double click tabs
        tabs.delegate(".tab-report", "dblclick", function () {
            var id = $(this).closest("li").remove().attr("aria-controls");
            $("#" + id).remove();
            tabs.tabs("refresh");
        });
        tabs.delegate(".tab-report", "mousedown", function (e) {
            if(e.which == 2){
                var id = $(this).closest("li").remove().attr("aria-controls");
                $("#" + id).remove();
                tabs.tabs("refresh");
            }
        });
        //
        tabs.bind("keyup", function (event) {
            if (event.altKey && event.keyCode === $.ui.keyCode.BACKSPACE) {
                var id = tabs.find(".ui-tabs-active").remove().attr("aria-controls");
                $("#" + id).remove();
                tabs.tabs("refresh");
            }
        });
    });
</script>
<div id="header">
    <div class="content">
        <a href="http://insight.webm.vn/" draggable="false"><img id="logo" src="./BuzzInsight_files/loginLogo.png" draggable="false"></a>
    </div>
</div>
<div id="control">
    <div class="content">
        <ul class="menu">
            <li class="report"><a title="Report" href="./BuzzInsight_files/BuzzInsight.htm" draggable="false">Report</a></li>
            <li class="management"><a title="Management" href="http://insight.webm.vn/management">Management</a></li>
            <li class="monitoring"><a title="Monitoring" href="http://insight.webm.vn/report#">Monitoring</a></li>
            <li class="setting1"><a title="Setting" href="http://insight.webm.vn/report#">Setting</a></li>
            <li class="setting"><a title="Setting" href="http://insight.webm.vn/setting">Setting</a></li>
			<li class="collection"><a title="Data Collection" href="http://insight.webm.vn/datacollection">Data Collection</a></li>
            <li class="logout"><a title="Logout" href="http://insight.webm.vn/user/logout">Log out</a></li>
        </ul>
    </div>
</div>